-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EZP-29518: ContentType option "Default field for sorting children" has no effect on new created objects #2428
Conversation
This is followup for #2421 as it got closed automatically after rebase. |
437b855
to
33d31f4
Compare
@@ -80,16 +81,20 @@ public function setSession($id) | |||
* Instantiates a new location create class. | |||
* | |||
* @param mixed $parentLocationId the parent under which the new location should be created | |||
* @param ContentType|null $contentType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use FQCN (applies to other places in this PR as well).
Changes requested by @alongosz completed + additional code: missing failsafe for not implemented sort fields. Ping @andrerom, @konradoboza. |
@@ -823,6 +824,14 @@ protected function buildSPILocationCreateStructs(array $locationCreateStructs) | |||
); | |||
} | |||
|
|||
if (!isset(Location::SORT_FIELD_MAP[$locationCreateStruct->sortField])) { | |||
$locationCreateStruct->sortField = Location::SORT_FIELD_NAME; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I would throw in this case, but that might be rather for kernel 8.x due to BC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, more of a 8.x way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is failsafe for when someone set it to not implemented sortField - which did nothing prev this PR - and after updating will create the new object of said ContentType, which now would break.
@mateuszbieniek Could you fix the PHP 5 incompatibility here so we can send it to QA? |
@andrerom done. |
$properties['sortField'] = $contentType->defaultSortField; | ||
$properties['sortOrder'] = $contentType->defaultSortOrder; | ||
} | ||
return new LocationCreateStruct($properties); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, not a blocker for QA here but seems CS check for some reason did not spot this (cs/travis conf wrong on 6.7?)
Afaik our CS profile dictates a empty line before return statements, right @alongosz ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, indeed fixer should complain here. Locally it does.
Tested with 1.7 seems OK, but I've got 2 questions:
Question 2:
|
@barbaragr 2: it should not be refreshed. Sorting field set in Content Type is a default one ONLY for newly created Content Object. Changing it changes sort field only for Content Objects that would be created afterward. This is the correct and expected behavior. |
@mateuszbieniek rebase is needed. |
b70df57
to
03227c6
Compare
Done @lserwatka |
You can merge it up |
@lserwatka done |
Thanks for fixing this @mateuszbieniek, nice improvment of kernel 👍 🎉 |
6.7+
Setting ContentType option "Default field for sorting children" had no effect on newly created Content Object of said ContentType - they were always set to default "Content Name Ascending". This PR fixes it.
TODO:
TODO ON MERGE